package com.epidemic.project.system.temperature.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.epidemic.project.system.temperature.domain.SysBodyTemperature;
import com.epidemic.project.system.temperature.service.ISysBodyTemperatureService;
import com.epidemic.framework.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import com.epidemic.framework.web.domain.AjaxResult;
import com.epidemic.common.utils.poi.ExcelUtil;
import com.epidemic.framework.web.page.TableDataInfo;

/**
 * 体温情况Controller
 *
 * @author sys
 * @date 2023-02-01
 */
@Controller
@RequestMapping("/system/temperature")
public class SysBodyTemperatureController extends BaseController
{
    private String prefix = "system/temperature";

    @Autowired
    private ISysBodyTemperatureService sysBodyTemperatureService;

    @GetMapping()
    public String temperature()
    {
        return prefix + "/temperature";
    }

    /**
     * 查询体温情况列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysBodyTemperature sysBodyTemperature)
    {
        startPage();
        List<SysBodyTemperature> list = sysBodyTemperatureService.selectSysBodyTemperatureList(sysBodyTemperature);
        return getDataTable(list);
    }

    /**
     * 导出体温情况列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysBodyTemperature sysBodyTemperature)
    {
        List<SysBodyTemperature> list = sysBodyTemperatureService.selectSysBodyTemperatureList(sysBodyTemperature);
        ExcelUtil<SysBodyTemperature> util = new ExcelUtil<SysBodyTemperature>(SysBodyTemperature.class);
        return util.exportExcel(list, "temperature");
    }

    /**
     * 新增体温情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存体温情况
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysBodyTemperature sysBodyTemperature)
    {
        return toAjax(sysBodyTemperatureService.insertSysBodyTemperature(sysBodyTemperature));
    }

    /**
     * 修改体温情况
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysBodyTemperature sysBodyTemperature = sysBodyTemperatureService.selectSysBodyTemperatureById(id);
        mmap.put("sysBodyTemperature", sysBodyTemperature);
        return prefix + "/edit";
    }

    /**
     * 修改保存体温情况
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysBodyTemperature sysBodyTemperature)
    {
        return toAjax(sysBodyTemperatureService.updateSysBodyTemperature(sysBodyTemperature));
    }

    /**
     * 删除体温情况
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysBodyTemperatureService.deleteSysBodyTemperatureByIds(ids));
    }
}
